package com.zb.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zb.dao.HouseinfoMapper;
import com.zb.entity.Houseinfo;
import com.zb.service.HouseinfoService;
import com.zb.utils.PageUtil;

@Service
public class HouseinfoServiceImpl implements HouseinfoService {

	@Autowired
	private HouseinfoMapper houseinfoMapper;

	@Override
	public Integer add(Houseinfo houseinfo) {
		Integer result = houseinfoMapper.add(houseinfo);
		return result;
	}

	@Override
	public PageUtil<Houseinfo> findByConditions(Integer startPageNo,
			Integer pageSize) {
		PageUtil<Houseinfo> result = new PageUtil<Houseinfo>();
		// 设置当前页
		result.setCurrentPageNo(startPageNo);
		// 设置页大小
		result.setPageSize(pageSize);
		// 设置数据量
		Integer totalCount = houseinfoMapper.findCount();
		result.setTotalCount(totalCount);
		// 设置数据
		Integer startIndexNo = (startPageNo - 1) * pageSize;
		List<Houseinfo> data = houseinfoMapper.findByConditions(startIndexNo,
				pageSize);
		result.setData(data);
		return result;
	}
}
